package com.bdqn.petmalldemo.common;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * @Author:彭俊
 * @description:自定义异常
 * @date:2020/2/131604
 */
@Data
@ApiModel
public class KetaiException extends RuntimeException {
    @ApiModelProperty(value = "异常状态码")
    private Integer code;

    /**
     * 自定义异常构造函数
     * @param message 异常信息
     * @param code  状态码
     */
    public KetaiException(String message, Integer code) {
        super(message);
        this.code = code;
    }
    /**
     * 根据枚举来创建自定义异常
     */
    public KetaiException(ResultCodeEnum resultCodeEnum){
        super(resultCodeEnum.getMsg());
        this.code=resultCodeEnum.getCode();
    }
}
